<template>
  <a-modal v-model="visible" :footer="null" title="支付配置 - 支付宝" width="40%">
    <a-spin :spinning="confirmSpin">
      <a-form-model
        ref="form"
        :model="configData"
        :rules="rules"
        :label-col="labelCol"
        :wrapper-col="wrapperCol">

        <a-form-model-item label="appId" prop="appId">
          <a-input v-model="configData.appId" placeholder="请输入 应用编号" :style="disable?{color:'black'}:{}"
                   :disabled="disable"/>
        </a-form-model-item>

        <a-form-model-item label="privateKey" prop="privateKey">
          <a-textarea
            v-model="configData.privateKey"
            placeholder="请输入应用私钥"
            :auto-size="{ minRows: 3, maxRows: 5 }"
            allowClear
            :style="disable?{color:'black'}:{}"
            :disabled="disable"
          />
        </a-form-model-item>

        <a-form-model-item label="publicKey" prop="publicKey">
          <a-textarea
            v-model="configData.publicKey"
            placeholder="支付宝公钥，通过应用公钥上传到支付宝开放平台换取支付宝公钥(如果是证书模式，公钥与私钥在CSR目录)"
            :auto-size="{ minRows: 3, maxRows: 5 }"
            allowClear
            :style="disable?{color:'black'}:{}"
            :disabled="disable"
          />
        </a-form-model-item>

        <a-form-model-item label="domain" prop="domain">
          <a-input v-model="configData.domain" placeholder="请输入 domain" :style="disable?{color:'black'}:{}"
                   :disabled="disable"/>
        </a-form-model-item>

        <a-form-model-item label="appCertPath">
          <a-input v-model="configData.appCertPath"
                   placeholder="应用公钥证书 (证书模式必须)"
                   :style="disable?{color:'black'}:{}"
                   :disabled="disable"/>
        </a-form-model-item>

        <a-form-model-item label="aliPayCertPath">
          <a-input v-model="configData.aliPayCertPath"
                   placeholder="支付宝公钥证书 (证书模式必须)"
                   :style="disable?{color:'black'}:{}"
                   :disabled="disable"/>
        </a-form-model-item>

        <a-form-model-item label="aliPayRootCertPath">
          <a-input v-model="configData.aliPayRootCertPath"
                   placeholder="支付宝根证书 (证书模式必须)"
                   :style="disable?{color:'black'}:{}"
                   :disabled="disable"/>
        </a-form-model-item>

        <a-form-model-item label="serverUrl">
          <a-input v-model="configData.serverUrl"
                   placeholder="支付宝支付网关"
                   :style="disable?{color:'black'}:{}"
                   :disabled="disable"/>
        </a-form-model-item>

        <a-form-model-item :wrapper-col="{ span: 14, offset: 7 }" v-if="!disable">
          <a-button type="primary" style="width:100px;" @click="onSubmit">
            修改
          </a-button>
          <a-button style="margin-left: 20px;width:100px;" @click="resetForm">
            重置
          </a-button>
        </a-form-model-item>
      </a-form-model>
    </a-spin>
  </a-modal>
</template>
<script>

import {BoneCommonMixin} from "@/mixins/BoneCommonMixin";
import {ConfigDictMixins} from "@views/gospel/configCenter/mixins/ConfigDictMixins";

export default {
  name: "AlipayModal",
  mixins: [BoneCommonMixin, ConfigDictMixins],
  data() {
    return {
      description: "支付宝配置",
      rules: {
        appId: [
          {required: true, message: '请输入 appId', trigger: 'blur'},
        ],
        privateKey: [
          {required: true, message: '请输入 privateKey', trigger: 'blur'},
        ],
        publicKey: [
          {required: true, message: '请输入 publicKey', trigger: 'blur'},
        ],
        domain: [
          {required: true, message: '请输入 domain', trigger: 'blur'},
        ],
      },
      type: "alipayConfig",
      configData: {
        appId: "",
        privateKey: "",
        publicKey: "",
        appCertPath: "",
        aliPayCertPath: "",
        aliPayRootCertPath: "",
        serverUrl: "",
        domain: "",
      },
      url: {
        configUpdate: "/config/pay/alipay",
      }
    }
  },
}
</script>

<style scoped>

</style>